import request from "@/utils/request";
const LOCAL = "localManger";
const LocalAPI = {
  getPodsByNamespace(cicdConfigId: number) {
    return request<any, ServiceInfo[]>({
      url: `${LOCAL}/${cicdConfigId}/serviceList`,
      method: "get",
    });
  },
  getConfigList(cicdConfigId: number, serviceCode: string) {
    return request<any, Map<string, Map<string, object>>>({
      url: `${LOCAL}/${cicdConfigId}/${serviceCode}/configList`,
      method: "get",
    });
  },
  saveConfig(cicdConfigId: number, serviceCode: string, fileName: string, content: string) {
    return request({
      url: `${LOCAL}/${cicdConfigId}/${serviceCode}/saveConfig`,
      method: "post",
      data: { fileName, content },
    });
  },
  getLogs(cicdConfigId: number, serviceCode: string) {
    return request<any, string>({
      url: `${LOCAL}/${cicdConfigId}/${serviceCode}/logs`,
      method: "get",
    });
  },
};

export default LocalAPI;

/**
 * 文件API类型声明
 */
export interface ServiceInfo {
  type: string;
  pid: string;
  port: string;
  command: Date;
  name: string;
}
